{% set pageTitle = (seoTitle if seoTitle else title) + ' - ' + site.title %}

{# We don't want any duplication. This is likely for the home page. #}
{% if site.title === title %}
  {% set pageTitle = title %}
{% endif %}

{% set siteTitle = site.title %}
{% set pageUrlSafe %}{{ page.url | stripDefaultLocale }}{% endset %}
{% set currentUrl = site.url + pageUrlSafe %}

{% if not description %}
  {% set description = site.description %}
{% endif %}


<title>{{ pageTitle }}</title>
<link rel="canonical" href="{{ currentUrl }}" />

{% if page.url %}
  {% Hreflang page.url, site, collections %}
{% endif %}

<meta property="og:site_name" content="{{ siteTitle }}" />
<meta property="og:title" content="{{ pageTitle }}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="{{ currentUrl }}" />

{% set socialImage = sharing_image or thumbnail or hero or site.defaultSocialImage %}

{% if socialImage %}
  {# Twitter thumbanils are 507px on their website, so this is a 3x version. #}
  {# This skips the filter and always rasterizes the image (auto=format) in case we have a SVG. #}
  {% set socialImageSrc = 'https://' + site.imgixDomain + '/' + socialImage + '?auto=format&w=1521' %}
  <meta name="twitter:card" content="summary_large_image" />
  <meta property="og:image" content="{{ socialImageSrc }}" />
  <meta name="twitter:image" content="{{ socialImageSrc }}" />

  {% if alt %}
    <meta property="og:image:alt" content="{{ alt }}" />
    <meta name="twitter:image:alt" content="{{ alt }}" />
  {% endif %}
{% endif %}

{% if description %}
  <meta name="description" content="{{ description }}" />
  <meta name="twitter:description" content="{{ description }}" />
  <meta property="og:description" content="{{ description }}" />
{% endif %}

{% if authors %}
  <meta name="authors" content="{{ authors | sort }}" />
{% endif %}

{% if tags %}
  <meta name="tags" content="{{ tags | sort }}" />
{% endif %}

<link rel="apple-touch-icon" sizes="180x180" href="/images/meta/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/meta/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/meta/favicon-16x16.png">
<meta name="theme-color" content="#ffffff">
